<!--预加载的css文件-->
<div id="css-file">
    <link rel="stylesheet" href="./lib/paginationjs/dist/pagination.css">
    <?php
    $mode = isset($_POST['mode']) ? $_POST['mode'] : 'common_list';
    if ($mode == 'media_list') {

        ?>
        <link rel="stylesheet" href="./css/dynamic_media_list.css">
        <?php
    } else {
        ?>
        <link rel="stylesheet" href="./css/dynamic_common_list.css">
        <?php
    }
    ?>
</div>
<!--预加载的script文件-->
<div id="script-file">
    <script data-src="./js/dynamic.js"></script>
</div>
<div class="dynamic-container container">
    <div class="row">
        <div class="col-md-8">
            <div class="title">
                <h3>
                    <?php
                    $mode = isset($_POST['mode']) ? $_POST['mode'] : 'common_list';
                    $cateNo = $_POST['cateNo'];
                    $type = isset($_POST['type']) ? $_POST['type'] : '';

                    $catesql = "select categoryName from tb_category where categoryNo =" . $cateNo;

                    echo mysqli_fetch_array(mysqli_query($link, $catesql))['0'];

                    ?>

                </h3>
                <?php
                if ($mode == 'media_list') {
                    ; ?>
                    <a href="mode=common_list" data-page-number=1 class="switch-mode">
                        <span class="glyphicon glyphicon-th-list"></span>普通列表
                    </a>
                    <?php
                } else {
                    ?>
                    <a href="mode=media_list" data-page-number=1 class="switch-mode">
                        <span class="glyphicon glyphicon-picture"></span>图文列表
                    </a>
                    <?php
                }; ?>
            </div>
            <div class="data-container">
                <ul class="news-list">
                    <?php
                    $mode = isset($_POST['mode']) ? $_POST['mode'] : 'media_list';
                    $pageNumber = isset($_POST['pageNumber']) ? $_POST['pageNumber'] : 1;
                    $pageSize = isset($_POST['pageSize']) ? $_POST['pageSize'] : 10;
                    $pageRange = isset($_POST['pageRange']) ? $_POST['pageRange'] : 1;//数据从数据库查，这是模拟数据

                    @include '../conn/conn.php';
                    if ($mode == 'media_list' || $mode == 'dynamic') {
                    //如果不是点击了二级栏目链接
                    if (empty($type) || $type != 'url') {
                        $pageRange = mysqli_num_rows(mysqli_query($link, "select * from tb_news where state = 1 and categoryNo= " . $cateNo));
                        $pageRange = ceil($pageNumber / $pageSize);
                        $sql = "select * from tb_news where state = 1  and categoryNo= " . $cateNo . " ORDER  BY  PlacedTop desc, publishTime desc limit " . ($pageNumber - 1) * $pageSize . "," . $pageSize;
                        //$sql="select*from tb_news where state = 1 and author = '$user' order  by no desc";
                        $result = mysqli_query($link, $sql);
                    } else {
                        $pageRange = mysqli_num_rows(mysqli_query($link, "select * from tb_news where state = 1 and no= " . $_POST['id'] . " and categoryNo= " . $cateNo));
                        $pageRange = ceil($pageNumber / $pageSize);
                        $sql = "select * from tb_news where state = 1  and categoryNo= " . $cateNo . " ORDER  BY  PlacedTop desc, publishTime desc limit " . ($pageNumber - 1) * $pageSize . "," . $pageSize;
                        //$sql="select*from tb_news where state = 1 and author = '$user' order  by no desc";
                        $result = mysqli_query($link, $sql);
                    }
                    if (mysqli_num_rows($result) > 0)  {
                    //echo '{"code":0,"msg":"","count":'.$count.',"data":[';
                    //  $i=1;

                    //					echo '当前页码：' . $pageNumber . ',页码范围:' . $pageRange . '每页条目数:' . $pageSize;

                    while ($row = mysqli_fetch_assoc($result)) {
                    ?>
                    <li class="clearfix">
                        <a href="ShowClass.php?<?php echo '#' . $cateNo . '/newsInfo?id=' . $row['no'] . '&cateNo=' . $cateNo; ?>">
                            <?php
                            echo '
					<h4 class="news-title">' . $row['title'] . '</h4>
					<div class="news-img pull-left">
					' . $row['NewsImg'] . '
					</div>
					<div class="news-body pull-right">
					' . $row['keywords'] . '
					<div class="news-footer clearfix">
					<p class="news-click pull-left"><span class="glyphicon glyphicon-eye-open"></span><span
					class="click-sum">23</span></p>
					<p class="news-date pull-right">' . $row['publishTime'] . '</p>
					</div>
					</div>
					</a></li>';
                            }
                            ?>
                            <?php

                            }
                            //mysqli_close($link);

                            } else if ($mode == 'common_list') {

                            //如果不是点击了二级栏目链接
                            if (empty($type) || $type != 'url') {
                                $pageRange = mysqli_num_rows(mysqli_query($link, "select * from tb_news where state = 1 and categoryNo= " . $cateNo));
                                $pageRange = ceil($pageNumber / $pageSize);
                                $sql = "select * from tb_news where state = 1  and categoryNo= " . $cateNo . " ORDER  BY  PlacedTop desc, publishTime desc limit " . ($pageNumber - 1) * $pageSize . "," . $pageSize;
                                //$sql="select*from tb_news where state = 1 and author = '$user' order  by no desc";
                                $result = mysqli_query($link, $sql);
                            } else {
                                $pageRange = mysqli_num_rows(mysqli_query($link, "select * from tb_news where state = 1 and no= " . $_POST['id'] . " and categoryNo= " . $cateNo));
                                $pageRange = ceil($pageNumber / $pageSize);
                                $sql = "select * from tb_news where state = 1  and categoryNo= " . $cateNo . " ORDER  BY  PlacedTop desc, publishTime desc limit " . ($pageNumber - 1) * $pageSize . "," . $pageSize;
                                //$sql="select*from tb_news where state = 1 and author = '$user' order  by no desc";
                                $result = mysqli_query($link, $sql);
                            }

                            if (mysqli_num_rows($result) > 0)  {
                            //echo '{"code":0,"msg":"","count":'.$count.',"data":[';
                            //  $i=1;

                            //					echo '当前页码：' . $pageNumber . ',页码范围:' . $pageRange . '每页条目数:' . $pageSize;

                            while ($row = mysqli_fetch_assoc($result)) {
                            ?>
                    <li class="clearfix">
                        <a href="ShowClass.php?<?php echo '#' . $cateNo . '/newsInfo?id=' . $row['no'] . '&cateNo=' . $cateNo; ?>">
                            <?php
                            echo '
					<h4 class="news-title pull-left">' . $row['title'] . '</h4>
					<div class="pull-right news-msg">
                           <p class="news-date pull-left"><span class="glyphicon glyphicon-time"></span>2017.10.12</p>
                           <p class="news-click pull-right">
                               <span class="glyphicon glyphicon-eye-open"></span>
                               <span class="click-sum">23</span>
                           </p>
                        </div>
					
					</a></li>';
                            }
                            }
                            }
                            ?>
                </ul>
            </div>

            <div id="pagination-btn"></div>
        </div>
        <div class="right-article col-md-4">
            <div class="art-hot-list panel panel-danger">
                <div class="panel-heading">
                    <h3 class="panel-title"><span class="glyphicon glyphicon-fire"></span> 近期热点</h3>
                </div>
                <ul class="list-group">
                    <li class="list-group-item clearfix">
                        <a href="" class="pull-left">计算机工程系LOGO设计大赛圆满落幕1</a>
                        <p class="news-click pull-right">
                            <span class="glyphicon glyphicon-eye-open"></span><span
                                    class="click-sum">23</span>
                        </p>
                    </li>
                    <li class="list-group-item clearfix">
                        <a href="" class="pull-left">计算机工程系LOGO设计大赛圆满落幕2</a>
                        <p class="news-click pull-right">
                            <span class="glyphicon glyphicon-eye-open"></span><span
                                    class="click-sum">23</span>
                        </p>
                    </li>
                    <li class="list-group-item clearfix">
                        <a href="" class="pull-left">计算机工程系LOGO设计大赛圆满落幕3</a>
                        <p class="news-click pull-right">
                            <span class="glyphicon glyphicon-eye-open"></span><span
                                    class="click-sum">23</span>
                        </p>
                    </li>
                    <li class="list-group-item clearfix">
                        <a href="" class="pull-left">计算机工程系LOGO设计大赛圆满落幕4</a>
                        <p class="news-click pull-right">
                            <span class="glyphicon glyphicon-eye-open"></span><span
                                    class="click-sum">23</span>
                        </p>
                    </li>
                    <li class="list-group-item clearfix">
                        <a href="" class="pull-left">计算机工程系LOGO设计大赛圆满落幕5</a>
                        <p class="news-click pull-right">
                            <span class="glyphicon glyphicon-eye-open"></span><span
                                    class="click-sum">23</span>
                        </p>
                    </li>
                </ul>
            </div>
        </div>
    </div>
</div>